package com.eatme.core.design.pattern.structural.facade;

public class GiftExchangeService {
    private QualifyService qualifyService = new QualifyService();

    private  PointPaymentService pointPaymentService = new PointPaymentService();

    private  ShippingService shippingService = new ShippingService();

    public void setQualifyService(QualifyService qualifyService) {
        this.qualifyService = qualifyService;
    }

    public void setPointPaymentService(PointPaymentService pointPaymentService) {
        this.pointPaymentService = pointPaymentService;
    }

    public void setShippingService(ShippingService shippingService) {
        this.shippingService = shippingService;
    }

    public void GiftExchange(PointsGift pointsGift) {
        if (qualifyService.isAvailable(pointsGift))
            // 资格校验通过
            if (pointPaymentService.pay(pointsGift)) {
                // 如果积分支付成功
                String shippingOrderNo = shippingService.shipGift(pointsGift);
                System.out.println("物流系统下单成功,订单号是:"+shippingOrderNo);
            }
    }
}
